import React, { Component } from 'react';

export default function MyErrorComponent(
  BgA: React.ComponentType<any>,
): React.ComponentType<any> {
  class bgA extends Component<any, any> {
    constructor(props: any) {
      super(props);
      this.state = {
        flag: false,
      };
    }

    static getDerivedStateFromError() {
      return {
        flag: true,
      };
    }
    componentDidCatch(err: any, errInfo: any) {
      console.log(err, errInfo);
    }
    render() {
      return (
        <>{this.state.flag ? <h1>报错了兄弟</h1> : <BgA {...this.props} />}</>
      );
    }
  }
  localStorage;
  return bgA;
}
